<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>


    <script src="../js/jquery.min.js"></script>

    <script src="https://cdn.bootcdn.net/ajax/libs/require.js/0.10.0/require.js"></script>

    <script type="text/javascript" src='https://cdn.jsdelivr.net/npm/marked/marked.min.js'></script>

    <link href="http://cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/highlight.js/8.0/highlight.min.js"></script>

<!--    <script type="application/javascript" src="../js/highlight.js/lib/languages/javascript.js"></script>-->
<!--    <script type="application/javascript" src="../js/highlight.js/lib/highlight.js.js"></script>-->

</head>
<body>

<div id="content" >

</div>

<div id="contentjs" style="background-color:#0000FF" >

</div>

<script>

    hljs.initHighlightingOnLoad();

    var rendererMD = new marked.Renderer();
    marked.setOptions({
        renderer: rendererMD,
        gfm: true,
        tables: true,
        breaks: false,
        pedantic: false,
        sanitize: false,
        smartLists: true,
        smartypants: false
    });
    // var markdownString = '```js\n console.log("hello"); \n```';
    // marked.setOptions({
    //     highlight: function (code) {
    //         return hljs.highlightAuto(code).value;
    //     }
    // });
    //
    // document.getElementById('content').innerHTML = marked(markdownString);



    let baseUrl = window.location.href.substring(0,window.location.href.lastIndexOf("/")+1);
    let url = baseUrl + 'readme.md';

    $.ajax({
        url:url,
        dataType:'text',
        processData: false,
        type:'get',
        success:function(data){
            // alert(data.name);
            // mak
            // marked(data);
            // document.getElementById("content").innerHTML=marked(data);

            var markdownString = marked(data);
            marked.setOptions({
                highlight: function (code) {
                    return hljs.highlightAuto(code).value;
                    // return require('../js/highlight.js/lib/highlight.js').highlightAuto(code).value;
                }
            });

            document.getElementById('content').innerHTML = marked(markdownString);
        },

        error:function(XMLHttpRequest, textStatus, errorThrown) {
            alert(XMLHttpRequest.status);
            alert(XMLHttpRequest.readyState);
            alert(textStatus);
        }});

    // highlight.js的同步高亮
    // marked.setOptions({
    //     highlight: function (code) {
    //         return require('../js/autoQR.js').highlightAuto(code).value;
    //     }
    // });
    //
    // document.getElementById('contentjs').innerHTML = marked(markdownString);




</script>
</body>
</html>